<style type="text/css">
<!--
.STYLE5 {font-size: 12px}
.STYLE7 {font-size: 12px; color: #FF0000; }
.STYLE11 {font-size: 12px; font-weight: bold; color: #000000; }
-->
</style>
      <div class="content bolr">
        <h2 class="h2">查看报名情况</h2>
        <div class="middle">
        <img src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_03.jpg" width="860" />
        <div class="h5"></div>
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
  <tr>
    <td height="30" colspan="13" align="center" bgcolor="#FFFFFF"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="18"><img src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_07.jpg" width="9" height="14" /></td>
        <td width="40"><a href="<?php echo $BM_HOME . "/results.php?cid=$cid";?>"><?php echo $MSG_GOBACK;?></a></td>
        <?php
        if ($is_admin)
        {
		?>
        <td width="10">|</td>
        <td width="18"><img src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_09.jpg" width="14" height="14" /></td>
        <td width="100"><a href="<?php echo $BM_HOME . "/results_download.xls.php?cid=$cid&ckind=0&xlskind=0";?>">下载报名详表</a></td>
        <td width="10">|</td>
        <td width="18"><img src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_09.jpg" width="14" height="14" /></td>
        <td width="100"><a href="<?php echo $BM_HOME . "/results_download.xls.php?cid=$cid&ckind=0&xlskind=1";?>">下载报名简表</a></td>
        <td width="10">|</td>
        <td width="18"><img src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_09.jpg" width="14" height="14" /></td>
        <td width="100"><a href="<?php echo $BM_HOME . "/zipdoc_download.php?cid=$cid&ckind=0".(isset($_GET['school']) ? ("&school=".$_GET['school']) : "");?>">打包下载文档</a></td>
       
        <?php 
        }
        ?>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="30" colspan="13" align="left" bgcolor="#ececec">
		<form id=sele action="results.php" method="get">
		<?php
		            if (isset($cid))
		                echo "<input type='hidden' name='cid' value='$cid'>";
		                
		            if (isset($ckind))
		                echo "<input type='hidden' name='ckind' value='$ckind'>";
		?>
    <table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center">筛选学校：</td>
        <td>
        	<select name="school" id="school">
        	<?php
            if (!isset($_GET['school']))
                $sele_school = -1;
            if ($sele_school < 0 || $sele_school >= $sele_school_cnt)
                $sele_school = -1;
            if ($sele_school == -1)
                echo "<option value='-1' selected>All</option>";
            else
                echo "<option value='-1'>All</option>";
            $i = 0;
            for ($i = 0; $i < $sele_school_cnt; $i++) {
                if ($i == $sele_school)
                    echo "<option value=$i selected>$to_sele_school[$i]</option>";
                else
                    echo "<option value=$i>$to_sele_school[$i]</option>";
            }
			?>
        	</select>        
        </td>
        <td><input type="image" name="imageField" id="imageField" src="<?php echo "./template/$BM_TEMPLATE/images/"; ?>04_14.jpg" /></td>
      </tr>
    </table>
		</form>
    </td>
    </tr>
  <tr>
    <td nowrap height="30" align="center" bgcolor="#d6d6d6"><span class="STYLE11">序号</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">学校</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">队伍名称</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11"><?php echo $MSG_COACH;?></span></td>
  	<?php 
  	if($is_admin)
  	{
  	?>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">联系方式</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">身份证</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">学号</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">姓名</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">专业</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">年级</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">性别</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">赛服尺寸</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">报名文档</span></td>
    <td nowrap align="center" bgcolor="#d6d6d6"><span class="STYLE11">删除队伍</span></td>
    <?php 
  	}
  	
  	        if (isset($_GET['school']) && $sele_school >= 0 && $sele_school < $sele_school_cnt) 
  	        {
                $cschool = $to_sele_school[$sele_school];
                $sql     = "
				SELECT * FROM `cr_team`
				WHERE `team_cid`='$contest_id' AND `team_school` = '$cschool' AND `team_kind` = 0
				ORDER BY `team_id` ASC
				";
            } 
            else 
            {
                $sql = "
				SELECT * FROM `cr_team`
				WHERE `team_cid`='$contest_id' AND `team_kind` = 0
				ORDER BY `team_school` ASC
				";
            }
            
            $result = mysql_query($sql);
            $cnt = 0;
            while ($row = mysql_fetch_array($result)) 
            {
            	if($cnt & 1) $BGCOL = "#D6D6D6";
            	else $BGCOL = "#ECECEC";
                $cnt++;
                $team_id     = $row['team_id'];
                $team_school = SqlToHtml($row['team_school']);
                $team_name   = SqlToHtml($row['team_name']);
                $team_coach  = SqlToHtml($row['team_coach']);
                $team_phone  = SqlToHtml($row['team_phone']);
                if ($is_admin) 
                {
                    echo "
                    <tr bgcolor=\"$BGCOL\">
                    	<td nowrap bgcolor=\"$BGCOL\" rowspan = '3'><span class=\"STYLE5\">$cnt</span></td>
                    	<td nowrap rowspan = '3'><span class=\"STYLE5\">$team_school</span></td>
                    	<td rowspan = '3'><span class=\"STYLE5\">$team_name</span></td>
                    	<td rowspan = '3'><span class=\"STYLE5\">$team_coach</span></td>
                    	<td rowspan = '3'><span class=\"STYLE5\">$team_phone</span></td>
                    	";
                    $sql  = "
							SELECT * FROM `cr_stu` 
							WHERE `team_id`='$team_id'
							ORDER BY `stu_123` ASC
							";
                    $lcnt = 0;
                    $lres = mysql_query($sql);
                    while ($lrow = mysql_fetch_array($lres)) 
                    {
                        $lcnt++;
                        if ($lcnt > 3)
                            break;
                        $team_id    = SqlToHtml($row['team_id']);
                        $stu_card   = SqlToHtml($lrow['stu_card']);
                        $stu_number = SqlToHtml($lrow['stu_number']);
                        $stu_name   = SqlToHtml($lrow['stu_name']);
                        $stu_major  = SqlToHtml($lrow['stu_major']);
                        $stu_grade  = SqlToHtml($lrow['stu_grade']);
                        $stu_sex    = SqlToHtml($lrow['stu_sex']);
                        $stu_cloth  = ($lrow['stu_cloth']);
                        echo "
	                        <td nowrap bgcolor=\"$BGCOL\"  height=\"30\"><span class=\"STYLE5\">$stu_card</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$stu_number</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$stu_name</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$stu_major</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$stu_grade</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">" . ($stu_sex ? "女" : "男") . "</span></td>
	                        <td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$stu_cloth</span></td>
	                        ";
                        if ($lcnt == 1)
                        {
                        	if(strlen($row['team_upload']))
                            echo "<td bgcolor=\"$BGCOL\" rowspan = '3'><span class=\"STYLE5\"><a href = '" . $BM_HOME.$row['team_upload'] . "'>下载文档</a></span></td>";
                          else
                          	echo "<td bgcolor=\"$BGCOL\" rowspan = '3'><span class=\"STYLE5\"><font color=red>尚未上传</font></span></td>";
                          echo "<td bgcolor=\"$BGCOL\" rowspan = '3'><span class=\"STYLE5\"><a href= '" . $BM_HOME . "/admin_delete.php?cid=$cid&tid=$team_id' onclick='return confirm(\"删除是不可恢复的，确认要删除吗？\");'>删除</a></span></td></tr>";
                        }
                        else
                            echo "</tr>";
                    }
                    while ($lcnt < 3)
                    {
                        $lcnt++;
                        echo "<td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">" . ($stu_sex ? "女" : "男") . "</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">未填写</span></td>";
                        if ($lcnt == 1)
                            echo "<td rowspan = '3'><span class=\"STYLE5\"><a href= '" . $BM_HOME . "/admin_delete.php?cid=$cid&tid=$team_id'>删除</a></span></td></tr>";
                        else
                            echo "</tr>";
                    }
                    
                    mysql_free_result($lres);
                } 
                else 
                {
                    echo "<tr bgcolor=\"$BGCOL\"><td height=\"30\"><span class=\"STYLE5\">$cnt</span></td><td ><span class=\"STYLE5\">$team_school</span></td><td ><span class=\"STYLE5\">$team_name</span></td><td bgcolor=\"$BGCOL\" ><span class=\"STYLE5\">$team_coach</span></td></tr>";
                }
            }
            
            mysql_free_result($result);
  	
  	
  	
  	
  	?>
  </tr>
  
</table>
</div>
<div style="height:150px;"></div>
